import 'package:Smart/pages/productor007/studytest/flutter_boss/pages/message/chat.dart';
import 'package:Smart/pages/productor007/studytest/flutter_boss/pages/message/interact.dart';
import 'package:flutter/material.dart';
// import 'package:flutter_boss/pages/message/chat.dart';
// import 'package:flutter_boss/pages/message/interact.dart';
// import 'package:flutter_boss/view/tab.dart';


class MessagePage extends StatefulWidget {
  MessagePage({Key key}) : super(key: key);

  @override
  _MessagePageState createState() => _MessagePageState();
}

class _MessagePageState extends State<MessagePage> with SingleTickerProviderStateMixin{
  
  TabController _tabController;
  List tabs = ["聊天", "互动"];
  

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = new TabController(
      length: 2,
      vsync: this,
    );

    //实现对_tabController 的监听  可以实现很多自定义的功能
    _tabController.addListener(() { 
      //监听tab改变 改变时打印出对应的索引值
      print(_tabController.index);

    });
  }
  
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title:TabBar(
          controller: this._tabController, //也可直接写_tabController
          isScrollable:true ,
          indicatorColor: Colors.red, //指示器颜色
          labelColor: Colors.white, //选中tab文字颜色
          unselectedLabelColor: Colors.grey,
          indicatorSize: TabBarIndicatorSize.label,
          labelStyle:TextStyle(fontSize: 18),
          tabs: tabs.map((e) => Tab(text: e)).toList(),
        ),
        actions: [
          IconButton(icon: Icon(Icons.notifications), onPressed: () {print("点击了菜单");}),
        ],
      ),
      body: TabBarView(
        controller: _tabController,
        children: <Widget>[
          chatPage(),
          interactPage(),
        ],
      ),
    );
  }
}